package nowcoder;
/**
 * 45846 --Fibonacci数列
 * 链接：https://www.nowcoder.com/practice/18ecd0ecf5ef4fe9ba3f17f8d00d2d66?tpId=85&&tqId=29846&rp=1&ru=/activity/oj&qru=/ta/2017test/question-ranking
 */
import java.util.*;
public class Day07_1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        // 0, 1, 1, 2, 3, 5, 8, 13, ...
        int cha1 = n - 0, cha2 = n - 1;
        int n1 = 0, n2 = 1;
        while(cha1 >= cha2){
            int temp = n2;
            n2 = n1 + n2;
            n1 = temp;
            cha1 = Math.abs(n - n1);
            cha2 = Math.abs(n - n2);
        }
        System.out.println(cha1);
    }
}
